﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Head{

    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="~/css/login.css" media="all">
}

<div class="layui-canvs"></div>
<div class="layui-layout layui-layout-login">
    <h1>
        <strong>庐山云雾茶管理系统后台</strong>
        <em>Management System</em>
    </h1>
    <form id="form">
        <div class="layui-user-icon larry-login">
            <input type="text" id="phoneNum" name="PhoneNum" placeholder="请输入电话号码" class="login_txtbx" />
        </div>
        <div class="layui-pwd-icon larry-login">
            <input type="password" id="passWord" name="PassWord" placeholder="密码" class="login_txtbx" />
        </div>
        <div class="layui-val-icon larry-login">
            <div class="layui-code-box">
                <input type="text" id="code" name="Code" placeholder="验证码" maxlength="4" class="login_txtbx">
                <img height="82px" src="/AdminLogin/GetValidCode" alt="" class="verifyImg" id="verifyImg" onClick="javascript: this.src = '/AdminLogin/GetValidCode?xx=' + Math.random();">
            </div>
        </div>
        <div class="layui-submit larry-login">
            <input type="button" value="立即登陆" class="submit_btn" />
        </div>
    </form>
    <div class="layui-login-text">
        <p>© 2018 Dev Team团队 版权所有</p>
        <p></p>
    </div>
</div>

@section FooterScript{
    <script type="text/javascript" src="~/common/layui/lay/dest/layui.all.js"></script>
    <script type="text/javascript" src="~/js/login.js"></script>
    <script type="text/javascript" src="~/jsplug/jparticle.jquery.js"></script>

    <script type="text/javascript">
        $(function () {
            $(".layui-canvs").jParticle({
                background: "#141414",
                color: "#E6E6E6"
            });

            //登录链接测试，使用时可删除
            $(".submit_btn").click(function () {
                var phone = $('#phoneNum').val();
                var pwd = $('#phoneNum').val();
                var code = $('#code').val();
                if (phone == "" || pwd == "" || code == "") {
                    layer.msg("手机号、密码或者验证码不可为空",{icon:2,time:1000});
                    return false;
                }
                if (!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(phone)) ) {
                    layer.msg("请输入正确的手机号", {});
                    return false;
                }


                var data = $('#form').serialize();
                var index = layer.load(1, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });
                $.ajax({
                    url: "/AdminLogin/Index",
                    data: data,
                    type: "post",
                    dataType: "json",
                    success: function (res) {
                        if (res.status == "ok") {
                            location.href = "/Main/Index";
                        } else if (res.status == "redirect") {
                            location.href = res.msg;
                        } else if (res.status == "error") {
                            layer.msg(res.errorMsg, { time: 1000, icon: 2 });
                        } else {
                            layer.msg("错误", { time: 1000, icon: 2 });
                        }
                        layer.close(index);
                        $('#verifyImg').attr('src','/AdminLogin/GetValidCode?xx=' + Math.random());;
                    }, error: function () {
                        layer.close(index);
                        layer.msg("请求失败", { icon: 2, time: 1000 });
                        $('#verifyImg').attr('src', '/AdminLogin/GetValidCode?xx=' + Math.random());;
                    }
                })
            });
        });
    </script>
}

